{% extends "shop/base.html" %}
{% load i18n %}
{% load satchmo_currency satchmo_discounts %}
{% load satchmo_tuning_category satchmo_tuning_cart %}

{% block extra-head %}
	<script type="text/javascript" src="{{ media_url }}js/jquery.js"></script>
	<script type="text/javascript" src="{{ media_url }}js/jquery.form.js"></script>
	<script type="text/javascript" src="{{ media_url }}js/satchmo_tuning.js"></script>
	<script type="text/javascript">
	$(document).ready(function() {
		satchmo_tuning.setup_add_to_cart_form();
		var items_in_cart = { {% items_in_cart_js cart %} };
		satchmo_tuning.update_product_list(items_in_cart);
	});
	</script>
{% endblock %}

{% block navbar %}
   <li class="first"><a href="{{ shop_base }}/">{% trans "Home" %}</a></li>
{% endblock %}

{% block content %}

{% if not results.categories and not results.products %}
<h4>{% trans "Nothing found" %}</h4>
{% else %}
	{% if category %}{% with results.categories.0.translated_name as category_name %}
		<h4>{% blocktrans %}Search results for {{ category_name }} products{% endblocktrans %}</h4>
	{% endwith %}
	{% else %}
	 	{% if results.categories %}
			<h4>{% trans "Categories" %}</h4>
			<ul>
		    {% for category in results.categories %}
		        {% ifchanged %}<li><a href="{{ category.get_absolute_url }}">{{ category.translated_name }}</a></li>{% endifchanged %}
		    {% endfor %}
			</ul>
		{% endif %}
	{% endif %}
	{% if results.products %}
		<div id="product_list">
			{% if not category %}
			<h4>{% trans "Products" %}</h4>
			{% endif %}
			{% with results.products as products %}
				{% include 'product/_products.html' %}
			{% endwith %}
		</div>
	{% else %}
		{% if category %}
			<p>{% trans "Nothing found" %}</p>
		{% endif %}
	{% endif %}
{% endif %}
{% endblock %}
